<?php

class M_admin extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    function get_count($data) {
        $this->db->from('admin');
        $this->db->select('count(1) as cnt');
        $this->db->where($data);
        $result = $this->db->get()->row_array();
        return $result['cnt'];
    }

    function get_admin($data) {
        if (isset($data['column'])) {
            $this->db->select($data['column']);
        }
        $this->db->from('admin');
        if (!isset($data['adminid'])) {
            return false;
        }
        $this->db->where('adminid', $data['adminid']);
        return $this->db->get()->row_array();
    }

    function get_all($data = array()) {
        if (isset($data['column'])) {
            $this->db->select($data['column']);
        }
        if (isset($data['where'])) {
            $this->db->select($data['where']);
        }
        $result = array();
        $query = $this->db->get('admin');
        foreach ($query->result_array() as $row) {
            $result[$row['adminid']] = $row;
        }
        return $result;
    }

}
